package com.zkx.laolaiyi.handler;

import com.zkx.laolaiyi.constant.ResultCodeConstant;
import com.zkx.laolaiyi.constant.ResultMsgConstant;
import com.zkx.laolaiyi.exceptions.BaseException;
import com.zkx.laolaiyi.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {
    @ExceptionHandler
    public Result<String> exceptionHandler(BaseException e) {
        log.error("全局异常处理器捕获异常：{}", e.getMessage());
        return Result.error(ResultCodeConstant.UNKNOWN_ERROR, ResultMsgConstant.UNKNOWN_ERROR);
    }
}
